package com.ebelter.myehc.ui.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ebelter.myehc.R;


/**
 * Created by ZCQ on 2017/12/1
 * 组合控件1 不知道怎么起名字了 还是按序号来吧
 */

public class CombinView5 extends LinearLayout{
    public CombinView5(Context context) {
        this(context,null);
    }




    public CombinView5(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }




    public CombinView5(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CombinView5);
        if (typedArray != null) {
            title1 = typedArray.getString(R.styleable.CombinView5_title1);
            title2 = typedArray.getString(R.styleable.CombinView5_title2);
            title3 = typedArray.getString(R.styleable.CombinView5_title3);
            typedArray.recycle();
        }

        initView(getContext());


    }

    private String title1;
    private String title2;
    private String title3;




    private TextView title1_tv;
    private TextView title2_tv;
    private TextView title3_tv;



    private void initView(Context context) {
        View view =  View.inflate(context, R.layout.cb5_layout, this);//把那个布局当做是自己的孩子

        title1_tv = view.findViewById(R.id.cb5_title1);
        title2_tv = view.findViewById(R.id.cb5_title2);
        title3_tv = view.findViewById(R.id.cb5_title3);

        setTitle1(title1);
        setTitle2(title2);
        setTitle3(title3);

    }

    public TextView getTitle1_tv() {
        return title1_tv;
    }

    public void setTitle1(String title1){
        this.title1=title1;
        if (title1_tv!=null){
            title1_tv.setText(this.title1);
        }
    }
    public void setTitle2(String title2){
        this.title2=title2;
        if (title2_tv!=null){
            title2_tv.setText(this.title2);
        }
    }
    public void setTitle3(String title3){
        this.title3=title3;
        if (title3_tv!=null){
            title3_tv.setText(this.title3);
        }
    }

}
